﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlueCrest.Sample.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using NUnit.Framework;

namespace BlueCrest.Sample.Tests
{
    [TestFixture]
    public class CachingWithProtoBufTests
    {
        [Test]
        public void CanGetDefault()
        {
            var factory = new CacheManagerFactory();

            var cacheManager = factory.Create("Default");

            cacheManager.Add("Test", ProtoBufTests.GetSampleAuthor());

            var fromCache = cacheManager.GetData("Test") as Author;

            Assert.IsNotNull(fromCache);
        }

        [Test]
        public void CanStoreAndGetProtoBuf()
        {
            var factory = new CacheManagerFactory();

            var cacheManager = factory.Create("ProtoBuf");

            cacheManager.Flush();

            cacheManager.Add("TestProtoBuf", ProtoBufTests.GetSampleAuthor());

            var fromCache = cacheManager.GetData("TestProtoBuf") as Author;

            Assert.IsNotNull(fromCache);
        }

        [Test]
        public void CanGetProtoBuf()
        {
            var factory = new CacheManagerFactory();

            var cacheManager = factory.Create("ProtoBuf");

            var fromCache = cacheManager.GetData("TestProtoBuf") as Author;

            Assert.IsNotNull(fromCache);
        }
    }
}
